package com.dc.refactoring._6_处理概括关系._7_ExtractSuperclass.oldObject;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * Description: 部门
 * @author: gdc
 * @date: 2020/12/13
 * @version 1.0
 */
public class Department {

    /**
     * 部门名称
     */
    private String name;
    /**
     * 员工列表
     */
    private List<Employee> employees = Lists.newArrayList();

    public Department(String name) {
        this.name = name;
    }

    /**
     * 获取年度成本
     */
    public Integer getTotalAnnualCost(){
        return getEmployees().stream().mapToInt(Employee::getAnnualCost).sum();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Employee> getEmployees() {
        return employees;
    }

    /**
     * 添加员工
     */
    public void addEmployees(Employee employee) {
        employees.add(employee);
    }
}
